#include "RakPeerInterface.h"
#include "RakNetworkFactory.h"
#include "BitStream.h"
#include "RakSleep.h"
#include <stdlib.h> // For atoi
#include <cstring> // For strlen
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include "MessageIdentifiers.h"
#include "LobbyClientInterface.h"
// Database specifications of input data, passed to some functions in the Lobby Client
#include "LobbyDBSpec.h"
#include "RankingServerDBSpec.h"
#include "TitleValidationDBSpec.h"
#include "EpochTimeToString.h"

#ifdef _CONSOLE_1
#elif defined (_CONSOLE_2)
#else
#include "LobbyClientPC.h"
#endif

extern bool quit;

using namespace RakNet;

class MyLobbyCallbacks : public LobbyClientInterfaceCB
{
	/// --- FUNCTION CALL RESULTS ---
	virtual void Login_Result(LobbyClientCBResult result);
	virtual void SetTitleLoginId_Result(LobbyClientCBResult result);
	virtual void Logoff_Result(LobbyClientCBResult result);
	virtual void RegisterAccount_Result(LobbyClientCBResult result);
	virtual void UpdateAccount_Result(LobbyClientCBResult result);
	virtual void ChangeHandle_Result(LobbyClientCBResult result);
	virtual void RetrievePasswordRecoveryQuestion_Result(LobbyClientCBResult result);
	virtual void RetrievePassword_Result(LobbyClientCBResult result);
	virtual void DownloadFriends_Result(LobbyClientCBResult result);
	virtual void SendAddFriendInvite_Result(LobbyClientCBResult result);
	virtual void AcceptAddFriendInvite_Result(LobbyClientCBResult result);
	virtual void DeclineAddFriendInvite_Result(LobbyClientCBResult result);
	virtual void DownloadIgnoreList_Result(LobbyClientCBResult result);
	virtual void AddToOrUpdateIgnoreList_Result(LobbyClientCBResult result);
	virtual void RemoveFromIgnoreList_Result(LobbyClientCBResult result);
	virtual void DownloadEmails_Result(LobbyClientCBResult result);
	virtual void SendEmail_Result(LobbyClientCBResult result);
	virtual void DeleteEmail_Result(LobbyClientCBResult result);
	virtual void UpdateEmailStatus_Result(LobbyClientCBResult result);
	virtual void SendIM_Result(LobbyClientCBResult result);
	virtual void CreateRoom_Result(LobbyClientCBResult result);
	virtual void DownloadRooms_Result(LobbyClientCBResult result);
	virtual void LeaveRoom_Result(LobbyClientCBResult result);
	virtual void JoinRoom_Result(LobbyClientCBResult result);
	virtual void JoinRoomByFilter_Result(LobbyClientCBResult result);
	virtual void RoomChat_Result(LobbyClientCBResult result);
	virtual void InviteToRoom_Result(LobbyClientCBResult result);
	virtual void SetReadyToPlayStatus_Result(LobbyClientCBResult result);
	virtual void KickRoomMember_Result(LobbyClientCBResult result);
	virtual void SetRoomIsHidden_Result(LobbyClientCBResult result);
	virtual void SetRoomAllowSpectators_Result(LobbyClientCBResult result);
	virtual void ChangeNumSlots_Result(LobbyClientCBResult result);
	virtual void GrantModerator_Result(LobbyClientCBResult result);
	virtual void StartGame_Result(LobbyClientCBResult result);
	virtual void SubmitMatch_Result(LobbyClientCBResult result);
	virtual void DownloadRating_Result(LobbyClientCBResult result);
	virtual void QuickMatch_Result(LobbyClientCBResult result);
	virtual void CancelQuickMatch_Result(LobbyClientCBResult result);
	virtual void DownloadActionHistory_Result(LobbyClientCBResult result);
	virtual void AddToActionHistory_Result(LobbyClientCBResult result);

	/// --- EVENT_NOTIFICATIONS ---
	virtual void ReceiveIM_Notify(const char *senderHandle, const char *body, LobbyClientUserId* senderId);
	virtual void FriendStatus_Notify(const char *friendName, LobbyClientUserId *friendId, FriendStatus status);
	virtual void IncomingEmail_Notify(LobbyClientUserId senderId, const char *senderHandle, const char *subject);
	virtual void FriendInvitation_Notify(FriendInvitation_Notification *notification);
	virtual void RoomMemberDrop_Notify(RoomMemberDrop_Notification *notification);
	virtual void RoomMemberJoin_Notify(RoomMemberJoin_Notification *notification);
	virtual void RoomMemberReadyStateChange_Notify(RoomMemberReadyStateChange_Notification *notification);
	virtual void RoomNewModerator_Notify(RoomNewModerator_Notification *notification);
	virtual void RoomSetIsHidden_Notify(RoomSetroomIsHidden_Notification *notification);
	virtual void RoomSetAllowSpectators_Notify(RoomSetAllowSpectators_Notification *notification);
	virtual void RoomChangeNumSlots_Notify(RoomChangeNumSlots_Notification *notification);
	virtual void ChatMessage_Notify(LobbyClientUserId *senderId, const char *senderHandle, const char *message,void *binaryData,unsigned int binaryDataLength);
	virtual void RoomInvite_Notify(LobbyClientUserId *senderId, const char *senderHandle, const char *message, void *binaryData,unsigned int binaryDataLength, LobbyClientRoomId *roomId, const char *roomName, bool privateSlotInvitation);
	virtual void RoomDestroyed_Notify(void);
	virtual void KickedOutOfRoom_Notify(KickedOutOfRoom_Notification *notification);
	virtual void QuickMatchTimeout_Notify(QuickMatchTimeout_Notification *notification);
	virtual void StartGame_Notify(StartGame_Notification *notification);

};

int mainlobby(void);
